#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int, int> PII;
typedef unsigned long long LL;
const int N = 1e5 + 10;
vector<PII> edges[N];
int n, pos, cntl;
bool st[N];
LL sum[N], nonl[N];

void dfs(int root)
{
    st[root] = true;
    for(auto t : edges[root])
    {
        int v = t.first, w = t.second;
        if(!st[v])
        {
            dfs(v);
            if(edges[v].size() == 0) 
            {
                sum[v] += w;
                cntl++;
            }
            else 
            {
                nonl[++pos] = w;
            }
            sum[root] += sum[v];
       }
    }
}

int main()
{
    int n; cin >> n;
    for(LL i = 1; i <= n; i++)
    {
        int fa, w; cin >> fa >> w;
        edges[fa].push_back({i, w});
    }
    
    dfs(0);
    
    if(sum[0] > 2200)
    {
        cout << "NO" << endl;
        return 0;
    }
    sort(nonl + 1, nonl + 1 + pos);
    sort(sum + 1, sum + 1 + n);
    // cout << cntl << " " << pos << endl;
    // for(int i = cntl + 1; i <= n; i++) cout << sum[i] << " ";
    // cout << endl;
    // for(int i = 1; i <= pos; i++) cout << nonl[i] << " ";
    for(int i = cntl + 1, j = 1; i <= n; i++, j++)
    {
        if(sum[i] > nonl[j])
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}